<template>
	<view :style="{'height':windowHeight}">
		<clothes></clothes>
		<view class="login"
			style="background: url(https://public-1329395846.cos.ap-nanjing.myqcloud.com/images/login.png);background-size: 100% 100%;background-repeat: no-repeat;">
			<view style="height: 25%;"></view>
			<view class="login-box">
				<view class="login-box-one">物联网卡登录</view>
				<view class="login-box-ipone">
					<input maxlength="11" placeholder="请输入卡密" type="number" v-model="ipone" />
				</view>

				<!-- <view class="login-box-s">
					<view class="login-box-s-img" v-if="iconType == 0" @click="iconClick">
						<image src="/static/qq1.png" mode=""></image>
					</view>
					<view class="login-box-s-img" v-if="iconType == 1" @click="iconClick1">
						<image src="/static/qq2.png" mode=""></image>
					</view>
					<view class="login-box-s-txt">
						我认真阅读
						<span @click="ShouCe">用户手册</span>
						和
						<span @click="ZhengCe">隐私政策</span>
					</view>
				</view> -->

				<view class="login-box-btn1" @click="Login">
					确认卡密
				</view>
				<view style="height: 48rpx;"></view>
			</view>
		</view>


	</view>
</template>
<script>
	export default {
		components: {},
		data() {
			return {
				windowHeight: "200px",
				iconType: 1,
				ipone: '1410063740',
				
				deviceId:'',
			}
		},
		onLoad() {
			this.GaoDu() //判断手机高度
		},
		onShow() {
			let that = this
			uni.getSystemInfo({
				success: function(res) {
					console.log(res, ']手机型号')
					that.deviceId = res.appId
				}
			});
		},
		methods: {
			// 登录
			Login() {
				if (this.ipone == '') {
					uni.showToast({
						title: '请输入卡密',
						icon: 'none',
						duration: 1000
					});
					return
				}
				
				this.$REQ(this.$api.queryAuthIot, {
					deviceId: this.deviceId,
					mapping:this.ipone,
				}, 'POST').then(res => {
					console.log(res)
					this.access_token = res.data.data.access_token
					uni.setStorage({
						key: 'info',
						data: res.data.data,
						success: function() {
							console.log('success');
						}
					});
					let iponeInfo = {
						mapping: this.ipone,
						deviceId: this.deviceId
					}
					uni.setStorage({
						key: 'iponeInfo',
						data: iponeInfo,
						success: function() {
							console.log('success');
						}
					});
					uni.reLaunch({
						url: '/pages/index/index'
					});
					setTimeout(() => {
						this.UserInfo(res.data.data.access_token) //用户信息
					}, 1000)
				}).catch(err => {
					console.log(err)
					uni.navigateTo({
						url: '/pages/loT/login/loginloT?mapping=' + this.ipone
					});
				})
				
				// uni.setStorage({
				// 	key: 'storage_key',
				// 	data: 'hello',
				// 	success: function () {
				// 		console.log('success');
				// 	}
				// });
				return
				uni.navigateTo({
					url: '/pages/loT/login/loginloT?mapping=' + this.ipone
				});
			},
			iconClick() {
				this.iconType = 1
			},
			iconClick1() {
				this.iconType = 0
			},
			// 判断手机高度
			GaoDu() {
				// 判断手机页面的高度
				uni.getSystemInfo({
					success: (res) => {
						this.windowHeight = res.windowHeight + "px";
					}
				})
			},
		}
	}
</script>

<style scoped lang="less">
	.login {
		width: 100%;
		height: 100%;
	}

	.login-box {
		width: 686rpx;
		background: #FFFFFF;
		border-radius: 16rpx;
		margin: auto;
	}

	.login-box-one {
		width: 330rpx;
		height: 40rpx;
		font-family: HarmonyOS_Sans_SC_Bold;
		font-size: 48rpx;
		color: #23292C;
		line-height: 40rpx;
		text-align: left;
		font-style: normal;
		padding-top: 64rpx;
		margin-left: 32rpx;
		padding-bottom: 48rpx;
		font-weight: 600;
	}

	.login-box-ipone {
		width: 622rpx;
		height: 112rpx;
		background: #F3F3F3;
		border-radius: 20rpx;
		margin: auto;
	}

	.login-box-ipone input {
		padding-left: 32rpx;
		padding-top: 32rpx;
	}

	.login-box-ipone1 {
		display: flex;
		flex-wrap: nowrap;
		justify-content: space-between;
		width: 622rpx;
		height: 112rpx;
		background: #F3F3F3;
		border-radius: 20rpx;
		margin: auto;
	}

	.login-code {
		padding-left: 32rpx;
		padding-top: 32rpx;
	}

	.login-txt {
		width: 170rpx;
		height: 36rpx;
		font-family: HarmonyOS_Sans_SC;
		font-size: 32rpx;
		color: #A9DEFA;
		line-height: 40rpx;
		text-align: left;
		font-style: normal;
		padding-top: 32rpx;
		padding-right: 32rpx;
	}

	.login-txt1 {
		width: 170rpx;
		height: 36rpx;
		font-family: HarmonyOS_Sans_SC;
		font-size: 32rpx;
		color: #00A5FF;
		line-height: 40rpx;
		text-align: left;
		font-style: normal;
		padding-top: 32rpx;
		padding-right: 32rpx;
	}

	.login-box-s {
		padding-left: 32rpx;
		padding-top: 16rpx;
		display: flex;
		padding-bottom: 32rpx;
	}

	.login-box-s-img {
		width: 32rpx;
		height: 32rpx;
		padding-top: 3rpx;
	}

	.login-box-s-img image {
		width: 100%;
		height: 100%;
	}

	.login-box-s-txt {
		font-family: HarmonyOS_Sans_SC;
		font-size: 28rpx;
		color: #666666;
		line-height: 39rpx;
		text-align: left;
		font-style: normal;
		padding-left: 10rpx;
	}

	.login-box-s-txt span {
		font-family: HarmonyOS_Sans_SC;
		font-size: 28rpx;
		color: #00A5FF;
		line-height: 39rpx;
		text-align: left;
		font-style: normal;
	}

	.login-box-btn {
		width: 622rpx;
		height: 112rpx;
		background: #A9DEFA;
		border-radius: 20rpx;
		margin: auto;
		font-family: HarmonyOS_Sans_SC;
		font-size: 32rpx;
		color: #FFFFFF;
		line-height: 40rpx;
		text-align: right;
		font-style: normal;
		text-align: center;
		line-height: 112rpx;
	}

	.login-box-btn1 {
		width: 622rpx;
		height: 112rpx;
		background: #18A8F7;
		border-radius: 20rpx;
		margin: auto;
		font-family: HarmonyOS_Sans_SC;
		font-size: 32rpx;
		color: #FFFFFF;
		line-height: 40rpx;
		text-align: right;
		font-style: normal;
		text-align: center;
		line-height: 112rpx;
		margin-top: 32rpx;
	}

	.ipone-prompt {
		font-family: HarmonyOS_Sans_SC;
		font-size: 28rpx;
		color: #ED0000;
		line-height: 39rpx;
		text-align: left;
		font-style: normal;
		padding-left: 64rpx;
		padding-top: 16rpx;
	}
</style>